#pragma once
#include "../MetaTable.h"
#include "../Signals.h"

namespace ECS
{
	class Assembly;

	/// Base component class.
	class Component
	{
		friend class Assembly;
		mtMETA_DEC;
	public:
		Component();
		virtual ~Component();
		Assembly* getAssembly() const;

		void destroy();

		template <class TComponent>
		TComponent* getComponent() const;

		bool isEnabled() const;
		void setEnabled(bool enabled);

		/// Adds associated connection
		void addConnection(const Connection& connection);

	protected:
		virtual void onEnabled(bool enabled);
		virtual void onDestroyed();
		void enableConnections(bool enable);
	private:
		std::vector<Connection> _connections;
		bool _enabled;
		Assembly* _assembly;
	};
}
